package com.example.play.controller;






import com.example.play.entity.Food;
import com.example.play.entity.User;
import com.example.play.service.FoodService;
import com.api.core.result.JsonResponse;
import com.api.core.result.PageView;
import com.example.play.request.FoodPageReq;
import com.example.play.request.FoodReq;
import com.example.play.service.FoodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import javax.annotation.Resource;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
/**
 * 美食(Food)表控制层
 *
 * @author makejava
 * @since 2022-02-26 13:44:35
 */
@Api(tags = "美食(Food)")
@RestController
@RequestMapping("food")
@Slf4j
public class FoodController {
    /**
     * 服务对象
     */
    @Resource
    private FoodService foodService;
 
    @PostMapping("/addFood")
    @ApiModelProperty("发布美食 ")
    public JsonResponse addFood(@RequestBody FoodReq foodReq) {

        return JsonResponse.success (foodService.addFood (foodReq));
    }

    @PostMapping("/findFoodList")
    @ApiModelProperty("查询美食 列表")
    public JsonResponse<PageView<Food>> findFoodList(@RequestBody FoodPageReq foodPageReq) {

       return JsonResponse.success ( foodService.findFoodList (foodPageReq));
                
    }

    @GetMapping("/getFoodById")
    @ApiModelProperty("查询美食 详情")
    public JsonResponse getFoodById(@RequestParam Integer foodId) {

        return JsonResponse.success (foodService.getFoodById (foodId));
    }

    @GetMapping("/deleteFood")
    @ApiModelProperty("删除美食 ")
    public JsonResponse deleteFood(@RequestParam Integer foodId) {

        return JsonResponse.success (foodService.deleteFood (foodId));
    }
    @PostMapping("/updateFood")
    @ApiModelProperty("修改 ")
    public JsonResponse updateFood(@RequestBody Food food) {

        return JsonResponse.success (foodService.update (food));
    }
}
